# 数据库连接配置
CONNECTION = {
    'host': 'pc-2ze0r0g1pdp5g8o59.rwlb.rds.aliyuncs.com',
    'port': 3306,
    'user': 'ykb_pro_use',
    'passwd': 'pass',
    'connect_timeout': 300,  # 连接超时时间
    'read_timeout': 600,     # 读取超时时间
    'write_timeout': 600,    # 写入超时时间
    'charset': 'utf8mb4',    # MySQL 5.7字符集
    'autocommit': True       # 自动提交事务
}

# 批量处理大小
# 针对4800万行数据，设置较大的批量处理量
BULK_SIZE = 1  # 调整为适合ES 7.7的批量大小

# Elasticsearch节点
NODES = ["http://test.es-inner.songliangcheng.com.cn"]

# 日志配置
 
LEVEL = 'INFO'
FORMAT='%(asctime)s - [%(process)d:%(thread)d] - %(pathname)s#%(lineno)d - %(name)s - %(levelname)s - %(message)s'


# 任务配置
TASKS = [
    {
        "stream": {
            "database": "api.letiku.net",  # 数据库名
            # 简单的SQL语句，程序会自动添加增量和分页条件
            "sql": "select * from yjy_user_action_log;",
            "pk": {"field": "id", "type": "int"},  # 设置主键字段和类型
            "batch_size": 8000  # 每批次处理的记录数
        },
        "jobs": [
            {
                "actions": ["insert", "update"],
                "pipeline": [
                    {"set_id": {"field": "id"}},  # 设置文档ID
                    # 如果只需要同步特定字段，可以取消下面的注释并修改字段列表
                    # {"only_fields": {"fields": ["id", "user_id", "nickname", "mobile", "app_id", "target", 
                    #                             "target_id", "target_name", "action_type", "title", 
                    #                             "created_at", "updated_at"]}},
                ],
                "dest": {
                    "es": {
                        "action": "upsert",
                        "index": "new_ykb_bbs_user_action_log_bak",   # 索引名称
                        "type": "_doc",          # ES 7.x 不再使用类型，但需要保留兼容
                        "nodes": NODES
                    }
                }
            }
        ]
    }
]
